package com.example.exception;

import com.example.common.enums.ResultCodeEnum;

/**
 * 自定义业务异常
 * 使用 JDK 21 优化，采用不可变设计
 */
public class CustomException extends RuntimeException {
    private final String code;
    private final String msg;

    public CustomException(ResultCodeEnum resultCodeEnum) {
        super(resultCodeEnum.msg);
        this.code = resultCodeEnum.code;
        this.msg = resultCodeEnum.msg;
    }

    public CustomException(String code, String msg) {
        super(msg);
        this.code = code;
        this.msg = msg;
    }

    public String getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }
}
